﻿<div ms-controller="TMP_RWGL">
    <!-- 添加按钮 -->
    <div class="btn-add">
        <button type="button" class="btn btn-info btn-lg" ms-click="AddView('RWGL')"><i class="iconfont icon-jiahao ft12 mr5"></i>添加任务</button>
        <a class="btn btn-info btn-lg" ms-click="dcrwgl()"><i class="iconfont icon-dc ft12 mr5"></i>导出</a>
    </div>
    <!-- 按条件选择 -->
    <div class="tab-filter-type">
        <div class="oh">
            <h5 class="pull-left tr">任务状态：</h5>
            <ul class="tab-type ft14">
                <li ms-click="ChangeType(0)"><span class="active">待办任务</span></li>
                <li ms-click="ChangeType(1)"><span>已办任务</span></li>
            </ul>
        </div>
        <div class="oh">
            <h5 class="pull-left tr">事项类型：</h5>
            <ul class="tab-type ft14">
                <li><span class="active" ms-click="SelectType('0')">全部</span></li>
                <li ms-click="SelectType('1')"><span>我负责的</span></li>
                <li ms-click="SelectType('2')"><span>我创建的</span></li>
                <li ms-click="SelectType('3')"><span>我参与的</span></li>
                <li ms-click="SelectType('4')"><span>抄送我的</span></li>
            </ul>
        </div>
        <div class="oh" style="display:none;">
            <h5 class="pull-left tr">任务分类：</h5>
            <ul class="tab-type ft14">
                <li ms-click="SelectRWType('')"><span class="active">全部</span></li>
                <li ms-repeat-el="TypeData" ms-click="SelectRWType(el.ID)"><span>{{el.TypeName}}</span></li>
            </ul>
        </div>
        <div class="oh" style="display:none;">
            <h5 class="pull-left tr">创建时间：</h5>
            <ul class="tab-type ft14">
                <li><span class="active" ms-click="SelectTime('')">全部</span></li>
                <li ms-click="SelectTime('1')"><span>近一周</span></li>
                <li ms-click="SelectTime('2')"><span>近一月</span></li>
                <li>
                    <span ms-click="SelectTime('3','1')">自定义</span>
                    <div class="pull-right ml10 zdy-text c999" ms-visible="curXJTime=='3'">
                        <input type="text" class="szhl_form_date szhl_require null" ms-duplex="starTime">
                        -
                        <input type="text" class="szhl_form_date szhl_require null" ms-duplex="endTime">
                        <input type="button" ms-click="SelectTime('3')" value="确定" style="width: 50px; background-color: #12B8F6;color:#ffffff" />
                    </div>
                </li>
            </ul>
        </div>

        <!-- 搜索 -->
        <div class="oh">
            <div class="input-group ml15" style="width:295px;">
                <input type="search" class="form-control" placeholder="搜索任务内容" ms-duplex="search.searchcontent">
                <span class="input-group-addon" ms-click="GetLIST()">搜索</span>
            </div>
        </div>
    </div>
    <!-- 展开更多选项 -->
    <div class="add-tab ft14 tc mt20">
        <span onclick="$('.oh').show(); $(this).parent().hide()">更多筛选<i class="caret"></i></span>
    </div>
    <!-- 表格 -->
    <div class="default-tab ft14 pt20 hover-btn">
        <table class="table table-striped table-responsive table-hover">
            <thead>
                <tr>
                    <th class="tc width-70">
                     
                        序号
                    </th>
                    <th>任务标题</th>
                    <th style="width:100px">截止日期</th>
               
                    <th style="width:80px;">
                    </th>
                </tr>
            </thead>
            <tbody>
                <tr ms-repeat-el="tmpListData" ms-click="ViewForm('RWGL_RWGL',el.ID,'',$event)">
                    <td class="tc">
                        {{$index+1+page.pagecount*(page.pageindex-1)}}
                    </td>
                    <td><span class="ico-radius-r" ms-class-1="color-red:el.RWStatus==0" ms-class-2="color-greed:el.RWStatus!=0"></span><span ms-class-3="red:el.RWStatus=='0'&&el.RWJZDate<nowTime">{{el.RWTitle}}</span><span ms-if="el.Files"><i class="iconfont icon-fj ft14 ml5"></i></span></td>
                    <td>{{el.RWJZDate}}</td>
                    <td>
               
                        <span class="btn-click">
                            <a class="cz-btn ft18 bj-color tip" data-toggle="tooltip" title="编辑" ms-if="el.CRUser==userName" ms-click="AddView('RWGL','修改任务',el.ID,$event)">
                                <i class="iconfont icon-bianji"></i>
                            </a>
                            <a class="cz-btn ft18 sc-color tip" data-toggle="tooltip" title="删除" ms-if="el.CRUser==userName" ms-click="Del(el,$event)">
                                <i class="iconfont icon-shanchu"></i>
                            </a>
                        </span>
                    </td>
                </tr>

            </tbody>
            <tfoot>
                <tr ms-if="isnull"><td class="tc"></td><td>暂无数据</td></tr>
            </tfoot>
        </table>
      
        <div class="ui-datatable-page ft14 pl20">

            <div class=" pl20" ms-if="tmpListData.size()!=0"><span class="ico-radius-r color-red"></span>待办任务</div>
            <div ms-if="tmpListData.size()!=0"><span class="ico-radius-r color-greed"></span>已办任务</div>
            <div class="red" ms-if="tmpListData.size()!=0"><span class="ico-radius-r color-red"></span>过期任务</div>

            <div id="pageDiv" ms-visible="model.page.total>model.pageNum[0].num" class="pull-right"></div>
            <div class="pull-right" ms-visible="tmpListData.size()!=0">
                <span>共{{model.page.total}}条记录</span>
                <span ms-visible="model.page.total>model.pageNum[0].num">
                    选择每页条数
                    <select style="height: 25px; width: 50px;" ms-change="selNum(this.value)" ms-duplex="model.page.pagecount">
                        <option ms-repeat-pg="pageNum" ms-attr-value="pg.num" ms-attr-selected="pg.num==model.page.pagecount?'selected':''">{{pg.num}}</option>
                    </select>
                </span>
            </div>
        </div>

    </div>
   
</div>

<script>

    var tempindex = avalon.define({
        $id: "TMP_RWGL",
        listType: 0,
        curRWType: "",
        curXJTime: "",
        starTime: "",
        endTime: "",
        nowTime: "",
        tmpListData: [],
        ChangeType: function (type) {
            tempindex.listType = type;
            tempindex.GetLIST();
        },
        SelectType: function (type) {
            model.search.seartype = type;
            tempindex.GetLIST();
        },
        SelectRWType: function (type) {
            tempindex.curRWType = type;
            tempindex.GetLIST();
        },
        SelectTime: function (type, item) {
            tempindex.curXJTime = type;
            if (!item) {
                if (type == '3') {
                    var a = (Date.parse(tempindex.starTime) - Date.parse(tempindex.endTime)) / 3600 / 1000;
                    if (a > 0) {
                        ComFunJS.winwarning("开始时间不能大于结束时间");
                    } else {
                        tempindex.GetLIST();
                    }
                } else {
                    tempindex.starTime = "";
                    tempindex.endTime = "";
                    tempindex.GetLIST();
                }
            }
        },
        selNum: function (item) {    //选择显示的条数
            model.page.pagecount = item;
            tempindex.GetLIST();
        },
        InitWigetData: function () {
            model.search.seartype = "0";
            //显示的列名
            model.ShowColumns.clear();
    
            tempindex.nowTime = ComFunJS.getnowdate("yyyy-mm-dd");
            model.GetTypeData("7");
            tempindex.GetLIST();
            model.isshowload = true;
            ComFunJS.initForm();

        },
        dcrwgl: function () {
            if (model.page.total > 0) {
                $(this).attr("href", "/API/VIEWAPI.ashx?Action=RWGL_EXPORTRW&P1=" + tempindex.listType + "&P2=" + model.search.seartype + "&pagecount=" + model.page.total + "&Content=" + model.search.searchcontent + "&lb=" + tempindex.curRWType + "&time=" + tempindex.curXJTime + "&starTime=" + tempindex.starTime + "&endTime=" + tempindex.endTime);
            }
            else {
                ComFunJS.winwarning("无数据");
            }
        },
        GetLIST: function () {
            model.page.total = 0;
            model.page.pageindex = 1;
            tempindex.tmpListData.clear();
            $.getJSON('/API/VIEWAPI.ashx?Action=RWGL_GETRWGLLIST',
                {
                    P1: tempindex.listType,
                    p: 1,
                    P2: model.search.seartype,
                    pagecount: model.page.pagecount,
                    Content: model.search.searchcontent,
                    lb: tempindex.curRWType,
                    time: tempindex.curXJTime,
                    starTime: tempindex.starTime,
                    endTime: tempindex.endTime
                }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        tempindex.tmpListData = resultData.Result;
                        if (tempindex.tmpListData.size() == 0) { model.isnull = true; } else { model.isnull = false; }
                        model.page.total = resultData.Result1;
                        laypage({
                            cont: 'pageDiv', //容器。值支持id名、原生dom对象，jquery对象。
                            pages: Math.ceil(parseInt(resultData.Result1) * 1.0 / model.page.pagecount), //通过后台拿到的总页数
                            curr: 1, //初始化当前页
                            skin: 'molv',
                            jump: function (e) { //触发分页后的回调
                                if (e.curr != model.page.pageindex) {
                                    $.getJSON('/API/VIEWAPI.ashx?Action=RWGL_GETRWGLLIST',
                                        {
                                            p: e.curr,
                                            P1: tempindex.listType,
                                            P2: model.search.seartype,
                                            pagecount: model.page.pagecount,
                                            Content: model.search.searchcontent,
                                            lb: tempindex.curRWType,
                                            time: tempindex.curXJTime,
                                            starTime: tempindex.starTime,
                                            endTime: tempindex.endTime
                                        }, function (resultData) {
                                            if (resultData.ErrorMsg == "") {
                                                tempindex.tmpListData = resultData.Result;
                                            }
                                        })
                                    model.page.pageindex = e.curr;
                                }
                            }
                        });
                    }

                })
        },
        Del: function (el, event) {
            if (event) {
                event.stopPropagation();
            }
            ComFunJS.winconfirm("确认要删除吗？", function () {
                $.getJSON("/API/VIEWAPI.ashx?Action=RWGL_DELRWGLMODEL", { P1: el.ID }, function (r) {
                    if (r.ErrorMsg == "") {
                        tempindex.tmpListData.remove(el);
                        ComFunJS.winsuccess("操作成功");
                    }
                })
            }, function () { })

        }
    })
    //# sourceURLRWGLTEMP.js;
</script>
